package com.bidevalution.business.function;

import java.util.Map;

import com.googlecode.aviator.runtime.function.AbstractFunction;
import com.googlecode.aviator.runtime.function.FunctionUtils;
import com.googlecode.aviator.runtime.type.AviatorObject;
import com.googlecode.aviator.runtime.type.AviatorString;
/**
 * 四舍五入计算
 * @author daizhifeng   
 * @date 2019年10月10日 下午9:39:47 
 * @version V2.0
 */
public class RoundFunction extends AbstractFunction{
	private FunctionInitializer functionInitializer;
	public RoundFunction(FunctionInitializer functionInitializer) {
		super();
		this.functionInitializer = functionInitializer;
	}
	/**
	 * 四舍五入
	 * <p>Description: </p>
	 * @param env
	 * @param arg1 值
	 * @return
	 * @see com.googlecode.aviator.runtime.function.AbstractFunction#call(java.util.Map, com.googlecode.aviator.runtime.type.AviatorObject)
	 */
	@Override
	public AviatorObject call(Map<String, Object> env, AviatorObject arg1) {
		return new AviatorString(String.valueOf(Math.round(Double.valueOf(arg1.getValue(env).toString()))));
	}
	@Override
	public String getName() {
		return "round";
	}
	public static void main(String[] args) {
		System.out.println(Math.round(0.7));
	}
}
